home *** CD-ROM | disk | FTP | other *** search
- Path: EU.net!sun4nl!xs4all!falstaff
- From: falstaff@xs4all.nl (Falstaff)
- Newsgroups: comp.lang.c
- Subject: Re: given: char foo[80]; there is no such thing as element foo[80] correct? (i.e. foo[80] = '\0' is beyond the array boundary)
- Date: 22 Mar 1996 14:04:57 GMT
- Organization: XS4ALL, networking for the masses
- Message-ID: <4iuc29$1ma@news.xs4all.nl>
- References: <314ad16d.86316693@news> <1996Mar16.175143.10948@zcon.com> <4ithke$mql@hermes.acs.unt.edu>
- NNTP-Posting-Host: xs1.xs4all.nl
- X-Newsreader: NN version 6.5.0 #666 (NOV)
-
- johnw@jove.acs.unt.edu (John R. Williams) writes:
-
- >Syed Zaeem Hosain (szh@zcon.com) wrote:
- >> >// Yes. This works nice and safely for any array of known size.
- >> >foo[sizeof(foo)-1] = '\0';
-
- >This is not safe even for strings if your character type is not
- >'char'. I know that sounds silly, but wchar_t *is* there for a reason,
- >y'know.
-
- John means that some compilers may choose to make wchar_t a short,
- and support Unicode. Of course, they would need to implement all
- string operations for normal and wide strings (no such thing as
- strlen() defined for wide strings in ANSI).
-
- Frank
- --
- The famous GIICM now on line: http://www.xs4all.nl/~falstaff/GIICM.html
- ------------------------------------------------------------------------
- Frank A. Vorstenbosch +31-(70)-355 5241 falstaff@xs4all.nl
-